﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

namespace School.Pages.Teaching
{
    public partial class Topic_Answer : System.Web.UI.Page
    {
        public string Stud_id;
        public string Question_Id;
        protected void Page_Load(object sender, EventArgs e)
        {
            Stud_id = Request.QueryString["Stud_id"].ToString();
            Question_Id = Request.QueryString["Question_Id"].ToString();
            if (!IsPostBack)
            {

                gvBank_A.DataSource = School.Teaching.Teaching.Get_Question_Bank_answer(Convert.ToInt32(Question_Id));
                gvBank_A.DataBind();
            }
        }
        protected void btnsave_Click(object sender, EventArgs e)
        {

            bool re = false;
            foreach (GridViewRow Row in gvBank_A.Rows)
            {
                RadioButton ch = (RadioButton)Row.FindControl("chcoice");
                int id = Convert.ToInt32(gvBank_A.DataKeys[Row.RowIndex].Value.ToString());
                //Question_Id
                int Question_Id = Convert.ToInt32(gvBank_A.DataKeys[Row.RowIndex].Values["Question_Id"].ToString());

                if (ch.Checked)
                {
                    re = School.Teaching.Teaching.Add_Student_Topic_Answer(Convert.ToInt32(Stud_id), Question_Id, id);

                }

            }
            if (re == true)
            {

                //GridView gvBank_Qin = (GridView)Page.PreviousPage.FindControl("gvBank_Qin");
                //DropDownList ddlTopic = (DropDownList)Page.PreviousPage.FindControl("ddlTopic");
                //if (ddlTopic.SelectedIndex > 0)
                //{
                //    gvBank_Qin.DataSource = School.Teaching.Teaching.Get_Topic_Q_inAnswer(Convert.ToInt32(ddlTopic.SelectedValue));
                //    gvBank_Qin.DataBind();
                //}
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "closeMe", "<script>window.parent.closeMe();</script>");
                //lbltst.ForeColor = Color.Green;
                //lbltst.Text = "تم التحديث بنجاح";
                //gvBank_QinBind();
            }
            else
            {
                //lbltst.ForeColor = Color.Red;
                //lbltst.Text = "لم تتم عملية التحديث..حاول مرة اخري";
            }
            //lbltst.Visible = true;

        }
    }
}